#region Copyright (c) 2004-2008 by Gael Fraiteur 
/*----------------------------------------------------------------------------*
 *   This file is part of run-time components of PostSharp.                    *
 *                                                                             *
 *   This library is free software: you can redistribute it and/or modify      *
 *   it under the terms of the version 3 of the GNU Lesser General Public      * 
 *   License as published by the Free Software Foundation.                     *
 *                                                                             *
 *   This library is distributed in the hope that it will be useful,           *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of            *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
 *   GNU General Public License for more details.                              *
 *                                                                             *
 *   You should have received a copy of the GNU Lesser General Public License  *
 *   along with this library.  If not, see <http://www.gnu.org/licenses/>.     *
 *                                                                             *
 *----------------------------------------------------------------------------*/
#endregion

using System;

namespace PostSharp.Extensibility
{
    /// <summary>
    /// Custom attribute that, when applied to an assembly, means that all assemblies that 
    /// reference this assembly need to be post-compiled by PostSharp.
    /// </summary>
    [AttributeUsage( AttributeTargets.Assembly, AllowMultiple=true )]
    public sealed class ReferencingAssembliesRequirePostSharpAttribute : Attribute
    {
        private readonly string plugIn;
        private readonly string task;

        /// <summary>
        /// Initializes a new instance of the <see cref="ReferencingAssembliesRequirePostSharpAttribute"/>
        /// custom attribute.
        /// </summary>
        /// <param name="task">Name of the task that is required to be executed on linked
        /// assemblies.</param>
        /// <param name="plugIn">Name of the plug-in that contains the task, or <b>null</b>
        /// if the declaring plugin was already loaded.</param>
        public ReferencingAssembliesRequirePostSharpAttribute( string task, string plugIn )
        {
            #region Preconditions

            if ( task == null )
            {
                throw new ArgumentNullException( "task" );
            }
            if ( plugIn == null )
            {
                throw new ArgumentNullException( "plugIn" );
            }

            #endregion

            this.task = task;
            this.plugIn = plugIn;
        }

        /// <summary>
        /// Gets or sets the name of the plug-in in which the task is located.
        /// </summary>
        /// <remarks>
        /// A file named after the value of the current property and having the extension
        /// <c>.psplugin</c> should exist in the search path.
        /// </remarks>
        public string PlugIn { get { return plugIn; } }

        /// <summary>
        /// Gets or sets the name of the task required by linked assemblies.
        /// </summary>
        /// <remarks>
        /// The task should either
        /// </remarks>
        public string Task { get { return task; } }
    }
}